package com.adtg.peru;

import java.util.ArrayList;

//import com.publicstaticdroidmain.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MyCustomBaseAdapter extends BaseAdapter {
	private static ArrayList<SearchResults> searchArrayList;

	private LayoutInflater mInflater;

	public MyCustomBaseAdapter(Context context, ArrayList<SearchResults> results) {
		searchArrayList = results;
		mInflater = LayoutInflater.from(context);
	}

	public int getCount() {
		return searchArrayList.size();
	}

	public Object getItem(int position) {
		return searchArrayList.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.list_item, null);
			holder = new ViewHolder();
			holder.txtTitulo = (TextView) convertView
					.findViewById(R.id.LblTitulo);
			holder.txtSubtitulo = (TextView) convertView
					.findViewById(R.id.LblSubTitulo);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		holder.txtTitulo.setText(searchArrayList.get(position).getTitulo());
		holder.txtSubtitulo.setText(searchArrayList.get(position)
				.getSubtitulo());

		return convertView;
	}

	static class ViewHolder {
		TextView txtTitulo;
		TextView txtSubtitulo;

	}
}
